package com.example.springprincle.config;

import com.example.springprincle.model.Doge;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
import org.springframework.web.context.annotation.ApplicationScope;
import org.springframework.web.context.annotation.RequestScope;
import org.springframework.web.context.annotation.SessionScope;

@Configuration
public class DogConfig {
    @Bean
    public Doge getDoge1(){
       Doge doge = new Doge();
       doge.setName("zhangsan");
       return doge;
    }

    /**
     * 单例模式
     * @return
     */
    @Bean
    @Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
    public Doge getDoge2(){
          return  new Doge();
    }


    /**
     * 原型作用域
     * @return
     */
    @Bean
    @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
    public Doge getDoge3(){
        return  new Doge();
    }



    @Bean
    @RequestScope
    public Doge getDoge4(){
        return  new Doge();
    }


    @Bean
    @SessionScope
    public Doge getDoge5(){
        return  new Doge();
    }


    @Bean
    @ApplicationScope
    public Doge getDoge6(){
        return  new Doge();
    }
}
